gtk: Improve struct packing in places
authorMatthias Clasen <mclasen@redhat.com>
Sat, 25 Jul 2020 02:57:34 +0000 (22:57 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 25 Jul 2020 15:57:37 +0000 (11:57 -0400)
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.

16 files changed:
gtk/gskpango.h
gtk/gtkadjustment.c
gtk/gtkapplicationwindow.c
gtk/gtkcolumnview.c
gtk/gtkcsstransition.c
gtk/gtkeventcontrollerkey.c
gtk/gtkfontbutton.c
gtk/gtkgridview.c
gtk/gtkprogresstrackerprivate.h
gtk/gtkrange.c
gtk/gtkscale.c
gtk/gtkswitch.c
gtk/gtktextlayoutprivate.h
gtk/gtktexttagprivate.h
gtk/gtkwidgetpaintable.c
gtk/gtkwidgetprivate.h

index bbd3699f4393925735f1ee09a6432ae20d875739..ab0933933ccaf948d9f8f1114f8663fb2ebd0bfa 100644 (file)
@@ -65,10 +65,10 @@ struct _GskPangoRenderer
   GdkRGBA               *error_color;
 
   GskPangoRendererState  state;
-  GskPangoShapeHandler shape_handler;
 
-  /* house-keeping options */
   guint                  is_cached_renderer : 1;
+
+  GskPangoShapeHandler   shape_handler;
 };
 
 struct _GskPangoRendererClass
index d4bf1ca8a1c82756cb3f689e51dfcfdf3a627ec4..1e6af5a59938c9d9e22d24c3cd166d4cc5286abf 100644 (file)
@@ -57,9 +57,9 @@ struct _GtkAdjustmentPrivate {
   double target;
 
   guint duration;
+  guint tick_id;
   gint64 start_time;
   gint64 end_time;
-  guint tick_id;
   GdkFrameClock *clock;
 };
 typedef struct _GtkAdjustmentPrivate GtkAdjustmentPrivate;
index eff8257e62ad7b6618f48407086c575228ab9a3a..54e393edd32d4b998a544f0c294099dc61d9e80c 100644 (file)
@@ -190,10 +190,9 @@ struct _GtkApplicationWindowPrivate
   GtkWidget *menubar;
 
   gboolean show_menubar;
+  guint id;
   GMenu *menubar_section;
 
-  guint            id;
-
   GtkShortcutsWindow *help_overlay;
 };
 
index b7a5b1bbe12a17ffc30e047deb220affa92c414b..6ad2580c2503364be18ebdf58960767b62fcf4e3 100644 (file)
@@ -118,21 +118,21 @@ struct _GtkColumnView
 
   GtkAdjustment *hadjustment;
 
-  gboolean reorderable;
-  gboolean show_column_separators;
+  guint reorderable : 1;
+  guint show_column_separators : 1;
+  guint in_column_resize : 1;
+  guint in_column_reorder : 1;
 
-  gboolean in_column_resize;
-  gboolean in_column_reorder;
   int drag_pos;
   int drag_x;
   int drag_offset;
   int drag_column_x;
 
-  GtkGesture *drag_gesture;
-
   guint autoscroll_id;
   double autoscroll_x;
   double autoscroll_delta;
+
+  GtkGesture *drag_gesture;
 };
 
 struct _GtkColumnViewClass
index fee6d66d7176c2820e5229e7516e7e889926ca19..98ef4b2f6a1ac324910edf24a902550cd8c2588b 100644 (file)
@@ -29,10 +29,10 @@ struct _GtkCssTransition
   GtkStyleAnimation parent;
 
   guint               property;
+  guint               finished;
   GtkCssValue        *start;
   GtkCssValue        *ease;
   GtkProgressTracker  tracker;
-  guint               finished;
 };
 
 
index ae7c11a8b0934ef6850b78a874486bb92f0fffb5..e813654be8489f5e6a11973a73f5050079e90470 100644 (file)
@@ -49,9 +49,9 @@ struct _GtkEventControllerKey
 
   GdkModifierType state;
 
-  GdkEvent *current_event;
-
   gboolean is_focus;
+
+  GdkEvent *current_event;
 };
 
 struct _GtkEventControllerKeyClass
index f7002bef7c43f3d649eb97439096f1134090a8db..0dcb9723d094962729eb3f4bc3d6a43820ac5925 100644 (file)
@@ -76,17 +76,19 @@ struct _GtkFontButton
   guint         show_preview_entry : 1;
   guint         modal    : 1;
 
+  GtkFontChooserLevel level;
+
   GtkWidget     *button;
   GtkWidget     *font_dialog;
   GtkWidget     *font_label;
   GtkWidget     *size_label;
   GtkWidget     *font_size_box;
 
+  int                   font_size;
   PangoFontDescription *font_desc;
   PangoFontFamily      *font_family;
   PangoFontFace        *font_face;
   PangoFontMap         *font_map;
-  int                   font_size;
   char                 *font_features;
   PangoLanguage        *language;
   char                 *preview_text;
@@ -94,8 +96,6 @@ struct _GtkFontButton
   gpointer              font_filter_data;
   GDestroyNotify        font_filter_data_destroy;
   GtkCssProvider       *provider;
-
-  GtkFontChooserLevel level;
 };
 
 struct _GtkFontButtonClass
index 7138a71aab077008111b1fdbbea7988c589128a5..1d243134a4563a6b62f90425b94117975371cdd4 100644 (file)
@@ -91,8 +91,8 @@ struct _GtkGridView
   guint max_columns;
   /* set in size_allocate */
   guint n_columns;
-  double column_width;
   int unknown_row_height;
+  double column_width;
 };
 
 struct _GtkGridViewClass
index 95adfe5f4d01ef9fef4703288d6b2f757c301cc4..fb635cccf9ea8e47d6d38a15fdd4c1905f2afbba 100644 (file)
@@ -35,11 +35,11 @@ typedef struct _GtkProgressTracker GtkProgressTracker;
 
 struct _GtkProgressTracker
 {
-  gboolean is_running;
   guint64 last_frame_time;
   guint64 duration;
   double iteration;
   double iteration_count;
+  gboolean is_running;
 };
 
 void                 gtk_progress_tracker_init_copy           (GtkProgressTracker *source,
index cc963ed2bc67c57762687bd7d985c04f3e637ad9..454240cfff7db6a200a1587c1d8a4a2dfff7e76f 100644 (file)
@@ -87,7 +87,7 @@ struct _GtkRangePrivate
   GtkWidget    *highlight_widget;
   GtkWidget    *slider_widget;
 
-  GtkOrientation     orientation;
+  GtkGesture *drag_gesture;
 
   double   fill_level;
   double *marks;
@@ -113,7 +113,7 @@ struct _GtkRangePrivate
   /* Whether dragging is ongoing */
   guint in_drag                : 1;
 
-  GtkGesture *drag_gesture;
+  GtkOrientation     orientation;
 
   GtkScrollType autoscroll_mode;
   guint autoscroll_id;
index 5e649eeaa24694dc124702816ccc936a8eee2e04..3c8056e63502ed2949170e42758cf35362fdd56f 100644 (file)
@@ -149,23 +149,23 @@ struct _GtkScalePrivate
 
   int           digits;
 
+  guint         draw_value : 1;
+  guint         value_pos  : 2;
+
   GtkScaleFormatValueFunc format_value_func;
   gpointer format_value_func_user_data;
   GDestroyNotify format_value_func_destroy_notify;
-
-  guint         draw_value : 1;
-  guint         value_pos  : 2;
 };
 
 struct _GtkScaleMark
 {
   double           value;
   int              stop_position;
+  GtkPositionType  position; /* always GTK_POS_TOP or GTK_POS_BOTTOM */
   char            *markup;
   GtkWidget       *label_widget;
   GtkWidget       *indicator_widget;
   GtkWidget       *widget;
-  GtkPositionType  position; /* always GTK_POS_TOP or GTK_POS_BOTTOM */
 };
 
 enum {
index 1c3bdd27c304ae6b7d37f5464b05be423ed3f86c..040519506e26656ec17af1e37fc9c1f2fa784776 100644 (file)
@@ -90,11 +90,12 @@ struct _GtkSwitch
 
   double handle_pos;
   guint tick_id;
-  GtkProgressTracker tracker;
 
   guint state                 : 1;
   guint is_active             : 1;
 
+  GtkProgressTracker tracker;
+
   GtkWidget *on_image;
   GtkWidget *off_image;
   GtkWidget *slider;
index 2ffab44fdd90f76fb1cc4a1a39797c425dd2e09b..2d563ae6ae90190e74744ad84f4a4c31c6c7d3e0 100644 (file)
@@ -154,14 +154,14 @@ struct _GtkTextLayout
   */
   guint keyboard_direction : 2;
 
+  guint overwrite_mode : 1;
+
   /* The preedit string and attributes, if any */
 
   char *preedit_string;
   PangoAttrList *preedit_attrs;
   int preedit_len;
   int preedit_cursor;
-
-  guint overwrite_mode : 1;
 };
 
 struct _GtkTextLayoutClass
index 4fe63d42490736d60662b4d2d5785a5292f1c852..28e4e1cce7dce656e779902d27b8e7f3bd405150 100644 (file)
@@ -39,10 +39,6 @@ struct _GtkTextTagPrivate
                          * a pointer to the key from the entry in
                          * tkxt->tagTable, so it needn't be freed
                          * explicitly. */
-  int priority;  /* Priority of this tag within widget.  0
-                         * means lowest priority.  Exactly one tag
-                         * has each integer value between 0 and
-                         * numTags-1. */
   /*
    * Information for displaying text with this tag.  The information
    * belows acts as an override on information specified by lower-priority
@@ -53,6 +49,10 @@ struct _GtkTextTagPrivate
 
   GtkTextAttributes *values;
 
+  int priority;  /* Priority of this tag within widget.  0
+                         * means lowest priority.  Exactly one tag
+                         * has each integer value between 0 and
+                         * numTags-1. */
   /* Flags for whether a given value is set; if a value is unset, then
    * this tag does not affect it.
    */
index 6b60c7ad28a86c9065f155c7cbd33543f05cc2e2..a2d6a0cc22fe061bdb2d81d011c58da91a9454f4 100644 (file)
@@ -60,9 +60,10 @@ struct _GtkWidgetPaintable
   GtkWidget *widget;
   guint snapshot_count;
 
+  guint         pending_update_cb;      /* the idle source that updates the valid image to be the new current image */
+
   GdkPaintable *current_image;          /* the image that we are presenting */
   GdkPaintable *pending_image;          /* the image that we should be presenting */
-  guint         pending_update_cb;      /* the idle source that updates the valid image to be the new current image */
 };
 
 struct _GtkWidgetPaintableClass
index 99a19afd9817221c73ff9ae58136d891aaccfc71..01090956ad05955de9984a769969b99f5ad37340 100644 (file)
@@ -51,10 +51,10 @@ typedef struct _GtkWidgetSurfaceTransformData
   GtkWidget *tracked_parent;
   guint parent_surface_transform_changed_id;
 
-  GList *callbacks;
-
   gboolean cached_surface_transform_valid;
+
   graphene_matrix_t cached_surface_transform;
+  GList *callbacks;
 } GtkWidgetSurfaceTransformData;
 
 struct _GtkWidgetPrivate
@@ -105,8 +105,9 @@ struct _GtkWidgetPrivate
   guint   halign              : 4;
   guint   valign              : 4;
 
+  guint user_alpha            : 8;
+
   GtkOverflow overflow;
-  guint8 user_alpha;
 
 #ifdef G_ENABLE_CONSISTENCY_CHECKS
   /* Number of gtk_widget_push_verify_invariants () */
@@ -115,13 +116,14 @@ struct _GtkWidgetPrivate
 
   int width_request;
   int height_request;
-  void (* resize_func) (GtkWidget *);
-  GtkBorder margin;
 
   /* Animations and other things to update on clock ticks */
   guint clock_tick_id;
   GList *tick_callbacks;
 
+  void (* resize_func) (GtkWidget *);
+  GtkBorder margin;
+
   /* Surface relative transform updates callbacks */
   GtkWidgetSurfaceTransformData *surface_transform_data;
 
@@ -152,10 +154,10 @@ struct _GtkWidgetPrivate
   int allocated_height;
   int allocated_size_baseline;
 
-  GskTransform *transform;
   int width;
   int height;
   int baseline;
+  GskTransform *transform;
 
   /* The widget's requested sizes */
   SizeRequestCache requests;